package com.xaicode.template.activemq.controller;

import com.xaicode.template.activemq.config.QueueProducer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author cjxia@isoftstone.com
 * @date 2022/4/18 0018 17:48
 */
@RestController
public class Provider {

    @Autowired
    private QueueProducer queueProducer;
    //注入存放消息的队列，用于下列方法一

    @GetMapping("/value")
    public String value() {
        String topic = "CRZS_TRANSFER_SYSTEM"; //自定义队列名称

        String magHeader = "\"IEMsgHeader\":{" +
                "\" IeType\": 1," +
                "\" MsgType\":\"CRZS_BELT_PUSH_REQ\"," +
                "\"MsgSn\":125368" +
                "}";

        String transfer = "\"IETransferStation\": {" +
                "\"IeType\": 54," +
                "\"Id\": \"123456\", " +
                "\"Name\":\"#5\" " +
                "}";
        String belt = "\"IEBelt\": {\n" +
                "\"IeType\": 55," +
                "\"Id\":\"123456\"," +
                "\"Name\":\"#5\"" +
                "\"Len\": 12" +
                "\"Width\": 260" +
                "\"Speed\":300 " +
                "\"MaxSpeed\": 310 " +
                "}";
        String msg = magHeader + transfer + belt;
        queueProducer.sendObjectMessage(topic, msg);   //发送到MQS
        return "消息已经发送";
    }

}
